package oa.struts.action;

import java.io.ByteArrayInputStream;
import java.util.Map;

import oa.util.SecurityCode;
import oa.util.SecurityImage;

import org.apache.struts2.interceptor.SessionAware;

import com.opensymphony.xwork2.ActionSupport;

public class SecurityCodeImageAction extends ActionSupport implements SessionAware {

	private Map<String,Object> session;
	//图片流
	private ByteArrayInputStream imageStream;
	
	public ByteArrayInputStream getImageStream() {
		return imageStream;
	}

	public void setImageStream(ByteArrayInputStream imageStream) {
		this.imageStream = imageStream;
	}
    public String execute() throws Exception
    {
    	String securityCode = SecurityCode.getSecurityCode();
        imageStream = SecurityImage.getImageAsInputStream(securityCode);
    	 //放入session中
    	session.put("SESSION_SECURITY_CODE", securityCode);
        return SUCCESS;

    }
	@Override
	public void setSession(Map<String, Object> session) {
		// TODO Auto-generated method stub
		this.session = session;
	}

}
